Skip to content

Fix NotImplementedError when eager loading BelongsToMany on a collection (#12)#21

Open
aleksanm wants to merge 1 commit into
masonitedev:3.xfrom
aleksanm:feature/12
Open

Fix NotImplementedError when eager loading BelongsToMany on a collection (#12)#21
aleksanm wants to merge 1 commit into
masonitedev:3.xfrom
aleksanm:feature/12

Conversation

@aleksanm

Copy link
Copy Markdown

Fixes #12.

Eager loading a BelongsToMany relationship onto a collection (Model.with_("rel").get()) raised NotImplementedError because BelongsToMany never overrode map_related. The single-model path (.first()) was unaffected, which is why it went unnoticed.

register_related already filters the related collection per-model, so map_related simply returns the result unchanged (matching HasOne). Added a regression test asserting each parent keeps its own related set.

🤖 Generated with Claude Code

…ev#12)

Eager loading a BelongsToMany relationship onto a collection
(Model.with_("rel").get()) raised NotImplementedError because
BelongsToMany never overrode map_related. register_related already
filters the related collection per-model, so map_related simply
returns the result unchanged (matching HasOne). Adds a regression
test asserting each parent keeps its own related set.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Eager loading a BelongsToMany relationship raises a NotImplementedError

1 participant